<%--
  Created by IntelliJ IDEA.
  User: bwj
  Date: 2021/6/23
  Time: 15:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">

    <title>
       区间修改
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="css/main.css" media="all">
    <script type="text/javascript" src="lib/loading/okLoading.js"></script>
    <link rel="stylesheet" href="css/bootstrap.css">
    <script src="<%=basePath%>js/jquery.min.js"></script>
    <link rel="stylesheet" href="fenye/myPagination.css">
    <script src="fenye/myPagination.js"></script>

</head>

<body>
<div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>首页</cite></a>
              <a><cite>订单管理</cite></a>
              <a><cite>区间添加</cite></a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon"
                                                                        style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <xblock>
        <button class="layui-btn">
            添加
        </button>
        <span class="x-right" style="line-height:40px"></span>
    </xblock>
    <form action="unit/add" method="post" id="add_unit">
        起始站：<select class="form-control" id="startsite.siteId"
                   name="startsite.siteId">
        <c:forEach items="${site}" var="s">
            <option value="${s.siteId}">
                    ${s.siteName}
            </option>
        </c:forEach>
    </select>
        <hr class="hr15">
        终点站: <select class="form-control" id="endsite.siteId"
                   name="endsite.siteId">

        <c:forEach items="${site}" var="s">
            <option value="${s.siteId}">
                    ${s.siteName}
            </option>
        </c:forEach>
    </select>
        <hr class="hr15">
        路程: <input name="mileage" id="mileage" type="text" value="" class="layui-input">
        <hr class="hr15">
        时间: <input name="travelTime" id="travelTime" type="text" value="" class="layui-input">
        <hr class="hr15">
        <div align="center">
            <button class="layui-btn" type="button" id="" lay-filter="add" lay-submit="">
                保存
            </button>
        </div>

    </form>
    <div id="page"></div>
</div>
<script src="lib/layui/layui.js" charset="utf-8"></script>
<script src="js/x-layui.js" charset="utf-8"></script>
<script>
    layui.use(['laydate', 'element', 'laypage', 'layer'], function () {
        $ = layui.jquery;//jquery
        laydate = layui.laydate;//日期插件
        lement = layui.element();//面包导航
        laypage = layui.laypage;//分页
        layer = layui.layer;//弹出层
        okLoading.close($);
        //以上模块根据需要引入


        var start = {
            min: '1999-06-16 23:59:59'
            , max: '2099-06-16 23:59:59'
            , istoday: false
            , choose: function (datas) {
                end.min = datas; //开始日选好后，重置结束日的最小日期
                end.start = datas //将结束日的初始值设定为开始日
            }
        };

        var end = {
            min: laydate.now()
            , max: '2099-06-16 23:59:59'
            , istoday: false
            , choose: function (datas) {
                start.max = datas; //结束日选好后，重置开始日的最大日期
            }
        };

        document.getElementById('LAY_demorange_s').onclick = function () {
            start.elem = this;
            laydate(start);
        }
        document.getElementById('LAY_demorange_e').onclick = function () {
            end.elem = this
            laydate(end);
        }
    });


    function question_show(argument) {
        layer.msg('可以跳到前台具体问题页面', {icon: 1, time: 1000});
    }

    //编辑
    function activity_edit(title, url, id, w, h) {
        url = url + "/" + id;
        x_admin_show(title, url, w, h);
    }

    /*删除*/
    function activity_del(obj, id) {
        layer.confirm('确认要删除吗？', {icon: 3, title: '提示信息'}, function (index) {
            $.ajax({
                type: "post",
                url: "site/delete",
                data: {id: id},
                dataType: "json",
                success: function (data) {
                    var i = parseInt(data);
                    if (i == 1) {
                        //发异步删除数据
                        $(obj).parents("tr").remove();
                        layer.msg(i.info, {icon: 6, time: 1000});
                        setTimeout(function () {
                            window.location.reload();
                        }, 1000);
                        return false;
                    } else {
                        layer.msg(i.info, {icon: 5, time: 1000});
                        return false;
                    }
                }
            });
            //发异步删除数据
            $(obj).parents("tr").remove();
            layer.msg('已删除!', {icon: 1, time: 1000});
        });
    }
</script>
<script type="text/javascript">
    function fenye(page) {

        var siteId = $('#siteId').val();
        var zhandian = $('#zhandian').val();
        var sheng = $('#sheng').val();
        var shi = $('#shi').val();
        if (siteId == "") {
            siteId = "!";
        }
        if (zhandian == "") {
            zhandian = "!";
        }
        if (sheng == "") {
            sheng = "!";
        }
        if (shi == "") {
            shi = "!";
        }
        var url = "order/" + page + "/" + siteId + "/" + zhandian + "/" + sheng + "/" + shi + "/fenye";
        location = url;
    }

</script>
<script>
    layui.use(['element', 'layer', 'form'], function () {
        $ = layui.jquery;//jquery
        lement = layui.element();//面包导航
        layer = layui.layer;//弹出层
        form = layui.form();
        okLoading.close($);

        //监听提交
        form.on('submit(add)', function updateCustomer() {
            $.post("unit/add", $('#add_unit').serialize(), function (obj) {
                var i = parseInt(obj);
                if (i > 0) {
                    alert("修改成功");
                    window.parent.location.reload();
                } else {
                    alert("修改失败");
                }
            });

        });
    });

</script>
</body>
</html>